/*
 *  Copyright 2019-2023 Zheng Jie
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package me.zhengjie.modules.system.rest;

import lombok.extern.slf4j.Slf4j;
import me.zhengjie.annotation.Log;
import me.zhengjie.exception.BizException;
import me.zhengjie.modules.system.domain.WxUser;
import me.zhengjie.modules.system.service.WxUserService;
import me.zhengjie.modules.system.domain.vo.WxUserQueryCriteria;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;

import java.sql.Date;
import java.text.SimpleDateFormat;
import java.time.LocalDate;


/**
 * @author yiwei.he
 * @date 2024-03-22
 **/
@RestController
@RequiredArgsConstructor
@Slf4j
@Api(tags = "微信用户（学生）")
@RequestMapping("/app/wxUser")
public class AppWxUserController{

    private final WxUserService wxUserService;

    @PostMapping
    @Log("查询微信用户（学生）")
    @ApiOperation("查询微信用户（学生）")
    public ResponseEntity<WxUser> queryWxUser(@RequestBody  WxUserQueryCriteria criteria){
        log.info("/app/wxUser 查询微信用户（）：{}",criteria);
        WxUser wxUser = wxUserService.selectById(criteria);
        return new ResponseEntity<>(wxUser,HttpStatus.OK);
    }

    @PostMapping("/update")
    @Log("修改微信用户信息（学生）")
    @ApiOperation("修改微信用户信息（学生）")
    public ResponseEntity<Object> updateWxUser(@Validated @RequestBody WxUser resources) throws BizException {
        log.info("/app/wxUser 修改微信用户信息（）：{}",resources);
        wxUserService.update(resources);
        return new ResponseEntity<>(HttpStatus.NO_CONTENT);
    }


}